package reduce.fz.com.reduce.activity;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.bean.Team;
import reduce.fz.com.reduce.fragment.FindTeamFragment;

public class FindTeamActivity extends BaseToolBarActivity {
    private Long categoryid;
    private final  static int  TEAM_CREATE=103;
    private FindTeamFragment fragment=null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setToolbarTitle("圈子列表");
        setRightBtn("新建").setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                forwardCreate();
            }
        });
        categoryid=getIntent().getLongExtra("categoryid",0);
        setContentView(R.layout.activity_find_team);
        fragment=FindTeamFragment.create(categoryid);
        this.getSupportFragmentManager().beginTransaction().replace(R.id.find_team_frameLayout, fragment).commit();
    }

    public void forwardCreate()
    {
        Intent intent=new Intent(FindTeamActivity.this,teamCreateActivity.class);
        intent.putExtra("categoryid",categoryid);
        startActivityForResult(intent,TEAM_CREATE);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode)
        {
            case TEAM_CREATE:
                if(data==null) return;
                Team team= (Team) data.getSerializableExtra("team");
                fragment.addFrist(team);
                break;
            default:
                break;
        }
    }

    @Override
    public void initWidget() {

    }

    @Override
    public void initListener() {

    }


}
